import http from "@/utils/http";

export const addTouristRouteAPI = (myData: {
  id: string;
  touristName: string;
  phoneNum: string;
  routeName: string;
  travelDays: number;
  departureLocation: string;
  departureTime: string;
  departureVehicle: string;
  returnLocation: string;
  returnTime: string;
  returnVehicle: string;
  creater:string;
  travelInformations: 
    {
      id: string;
      travelDate: string;
      destination: string;
      hotelAccomodation: string;
      theatricalPerformance: string;
      price: number;
      touristRouteId: string;
      order:number;
      vehicle:string;
      travelScenicInformations: 
        {
          id: string;
          travelInformationId: string;
          scenicSpotId: string;
          scenicSpot: {
            id: string;
            name: string;
            pictureUrl: string;
            description: string;
            price: number;
            belongCity: string;
            cityId: string;
          };
        }[];
    }[];
}) => {
  return http({
    url: "/api/v1/touristRoute/add",
    method: "POST",
    data: {
      ...myData,
    },
  });
};

export const getTouristAPI = (touristRouteId: string) => {
  return http({
    url: "/api/v1/touristRoute/get",
    method: "GET",
    params: {
      touristRouteId,
    },
  });
};

export const updateTouristRouteAPI = (myData: {
  id: string;
  touristName: string;
  phoneNum: string;
  routeName: string;
  travelDays: number;
  departureLocation: string;
  departureTime: string;
  departureVehicle: string;
  returnLocation: string;
  returnTime: string;
  returnVehicle: string;
  creater:string;
  travelInformations: 
    {
      id: string;
      travelDate: string;
      destination: string;
      hotelAccomodation: string;
      theatricalPerformance: string;
      price: number;
      touristRouteId: string;
      order:number;
      vehicle:string;
      travelScenicInformations: 
        {
          id: string;
          travelInformationId: string;
          scenicSpotId: string;
          scenicSpot: {
            id: string;
            name: string;
            pictureUrl: string;
            description: string;
            price: number;
            belongCity: string;
            cityId: string;
          };
        }[];
    }[];
}) => {
  return http({
    url: "/api/v1/touristRoute/update",
    method: "POST",
    data: {
      ...myData,
    },
  });
};

export const getAllTouristAPI = (page: number, pageSize: number) => {
  return http({
    url: "/api/v1/touristRoute/queryPersonalByPage",
    method: "GET",
    params: {
      page,
      pageSize,
    },
  });
};

export const deleteTouristRouteAPI = (tourisRouteId: string) => {
  return http({
    url: "/api/v1/touristRoute/delete",
    method: "DELETE",
    params: {
      tourisRouteId,
    },
  });
};
